import { ColumnProps } from '~/library/components/ProTable/interface'
import { Procure } from '~/src/api/interface/procure'
import { getStoreHouseAPI } from '~/src/api/procure'
import { getLastQuarterDays } from '~/src/utils/date'
import { formatDate } from '~/src/utils/date-formatter'
import { warehouseStatus } from '~/src/utils/serviceDict'

export const receiveSheetColumns: ColumnProps<Procure.BreakageSheet>[] = [
  { type: 'index', label: '序号', width: 60 },
  {
    prop: 'outDate',
    label: '业务日期',
    minWidth: 164,
    search: {
      el: 'date-picker',
      key: 'timeValue',
      order: 1,
      defaultValue: [formatDate(-getLastQuarterDays(), 'start', 'yyyy-MM-dd'), formatDate(0, 'end', 'yyyy-MM-dd')],
      props: {
        type: 'datetimerange',
        format: 'YYYY-MM-DD',
        valueFormat: 'YYYY-MM-DD',
      },
    },
    align: 'left',
  },
  { prop: 'orderNo', label: '单据编号', minWidth: 180, align: 'left', search: { el: 'input' } },
  // { prop: "trackingNo", label: "物流单号", minWidth: 200, align: "left" },
  // { prop: "LogisticsName", label: "物流公司", width: 130, align: "left" },
  { prop: 'customerName', label: '客户', width: 120, align: 'left' },
  {
    prop: 'checkFlagName',
    label: '单据状态',
    width: 110,
    align: 'left',
    enum: warehouseStatus,
    isFilterEnum: false,
    search: { el: 'select', key: 'checkFlag' },
  },
  {
    prop: 'houseName',
    label: '领用仓库',
    width: 110,
    align: 'left',
    search: { el: 'select', key: 'houseId' },
    enum: () => getStoreHouseAPI({ pageNum: 1, pageSize: 9999 }),
    fieldNames: { label: 'name', value: 'id' },
    isFilterEnum: false,
  },
  { prop: 'departmentName', label: '领用部门', width: 110, align: 'left' },
  { prop: 'staffName', label: '领用人', width: 110, align: 'left' },
  { prop: 'customerName', label: '领用类型', width: 110, align: 'left' },
  { prop: 'createTime', label: '创建时间', minWidth: 164, align: 'left' },
  { prop: 'operation', label: '操作', width: 220, fixed: 'right' },
]

export const receiveDetailColumns: ColumnProps<any>[] = [
  { type: 'index', label: '序号', width: 60 },
  { prop: 'operate', label: '操作', width: 80 },
  { prop: 'barcode', label: '编码', minWidth: 220 },
  { prop: 'goodsName', label: '名称', minWidth: 140 },
  { prop: 'productName', label: '规格', width: 110 },
  { prop: 'quantity', label: '数量', width: 110 },
  { prop: 'costPrice', label: '单价', minWidth: 120 },
  { prop: 'amount', label: '金额', width: 110 },
  { prop: 'planQuantity', label: '当前库存', width: 110 },
  { prop: 'unitName', label: '单位名称', width: 110 },
  { prop: 'remark', label: '备注', width: 180 },
]
